package cn.lsj.lsjzklocktest.controller;


import cn.lsj.lock.annotation.GlobalLock;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {
//
//    @Resource
//    @Qualifier("lock")
//    private ReentrantLock lock;
////
//    @Resource
//    @Qualifier("countLock")
//    private ReentrantLock countLock;


    int count = 0;

    @GetMapping("test")
    @GlobalLock("countLock")
    public String test() {
//        countLock.lock();
        try{
            for (int i = 0; i < 10000; i++) {
                count++;
            }
        } finally {
//            countLock.unlock();
        }
        return String.valueOf(count);
    }
}
